home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / gcc270_src.lha / gcc-2.7.0-amiga / config / m68k / amigados.c < prev    next >
C/C++ Source or Header  |  1995-08-24  |  6KB  |  206 lines

  1. /* Definitions of target machine for GNU compiler.  amiga 68000/68020 version.
  2.    Copyright (C) 1992 Free Software Foundation, Inc.
  3.    Contributed by Markus M. Wild (wild@amiga.physik.unizh.ch).
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #include "m68k/m68k.c"
  22.  
  23. /* Does operand (which is a symbolic_operand) live in text space? If
  24.    so SYMBOL_REF_FLAG, which is set by ENCODE_SECTION_INFO, will be true.
  25.  
  26.    This function is used in base relative code generation. */
  27.  
  28. int
  29. read_only_operand (operand)
  30.      rtx operand;
  31. {
  32.   if (GET_CODE (operand) == CONST)
  33.     operand = XEXP (XEXP (operand, 0), 0);
  34.   if (GET_CODE (operand) == SYMBOL_REF)
  35.     return SYMBOL_REF_FLAG (operand) || CONSTANT_POOL_ADDRESS_P (operand);
  36.   return 1;
  37. }
  38.  
  39.  
  40. /* the rest of the file is to implement AmigaDOS specific keywords some day.
  41.    The approach used so far used __attribute__ for this, but this required
  42.    changes to c-parse.y as well as if we'd use the common keywords used
  43.    on commercial AmigaDOS C-compilers as well. So in the future I'll probably
  44.    switch to __saveds and __interrupt keywords as well.
  45.  
  46.    The rest of this file is currently ignored, because it's no longer
  47.    working with the current gcc version. */
  48.  
  49. #if not_yet_working
  50.  
  51. #include "tree.h"
  52.  
  53. struct attribute {
  54.   tree ident;
  55.   int  saveds : 1,
  56.        interrupt : 1;
  57. };
  58.  
  59.  
  60. static struct attribute *a_tab = 0;
  61. static int a_index, a_size;
  62.  
  63. void
  64. add_attr_entry (attr)
  65.     struct attribute *attr;
  66. {
  67.   if (! a_tab)
  68.     {
  69.       a_size = 10;
  70.       a_index = 0;
  71.       a_tab  = (struct attribute *) xmalloc (a_size * sizeof (struct attribute));
  72.     }
  73.  
  74.   if (a_index == a_size)
  75.     {
  76.       a_size <<= 1;
  77.       a_tab = (struct attribute *) xrealloc (a_tab, a_size * sizeof (struct attribute));
  78.     }
  79.  
  80.   a_tab[a_index++] = *attr;
  81. }
  82.  
  83.  
  84. void
  85. attr_do_saveds (function_ident)
  86.       tree function_ident;
  87. {
  88.   struct attribute attr, *a;
  89.   int i;
  90.  
  91.   for (i = 0, a = a_tab; i < a_index; i++, a++)
  92.     if (a->ident == function_ident)
  93.       {
  94.     a->saveds = 1;
  95.     return;
  96.       }
  97.  
  98.   /* create a new entry for this function */
  99.   attr.ident     = function_ident;
  100.   attr.saveds    = 1;
  101.   attr.interrupt = 0;
  102.   add_attr_entry (&attr);
  103. }
  104.  
  105. void
  106. attr_do_interrupt (function_ident)
  107.     tree function_ident;
  108. {
  109.   struct attribute attr, *a;
  110.   int i;
  111.  
  112.   for (i = 0, a = a_tab; i < a_index; i++, a++)
  113.     if (a->ident == function_ident)
  114.       {
  115.     /* __interrupt implies __saveds */
  116.     a->saveds    = 1;
  117.     a->interrupt = 1;
  118.     return;
  119.       }
  120.  
  121.   /* create a new entry for this function */
  122.   attr.ident     = function_ident;
  123.   attr.saveds     = 1;
  124.   attr.interrupt = 1;
  125.   add_attr_entry (&attr);
  126. }
  127.  
  128. int
  129. attr_does_saveds (function_name)
  130.     char *function_name;
  131. {
  132.   tree ident = get_identifier (function_name);
  133.   struct attribute *attr;
  134.   int i;
  135.   
  136.   for (i = 0, attr = a_tab; i < a_index; i++, attr++)
  137.     if (attr->ident == ident)
  138.       return attr->saveds;
  139.  
  140.   return 0;
  141. }
  142.  
  143. int
  144. attr_does_interrupt (function_name)
  145.     char *function_name;
  146. {
  147.   tree ident = get_identifier (function_name);
  148.   struct attribute *attr;
  149.   int i;
  150.   
  151.   for (i = 0, attr = a_tab; i < a_index; i++, attr++)
  152.     if (attr->ident == ident)
  153.       return attr->interrupt;
  154.  
  155.   return 0;
  156. }
  157.  
  158. #endif
  159.  
  160. /*
  161. Stack checking and auto-extend
  162.  
  163. This is my first attempt to implement stack extension with gcc.
  164. If you think some things should be changed please write
  165. to me immediately (fleischr@izfm.uni-stuttgart.de, or even better
  166. to amiga-gcc-port@lists.funet.fi for discussion).
  167.  
  168. If you don't want to recompile gcc (to check it out) you can still
  169. test the example supported (bigtest.c) or read the documentation.
  170. Simply do a 'make' to build it.
  171.  
  172. Matthias
  173. */
  174.  
  175. rtx gen_stack_management_call (stack_pointer, arg, func)
  176.      rtx stack_pointer; /* rtx to put the result into       */
  177.      rtx arg;           /* The argument to put into d0      */
  178.      char *func;        /* The name of the function to call */
  179. {
  180.   rtx fcall, assem;
  181.   emit_move_insn (gen_rtx (REG, SImode, 0), arg); /* Move arg to d0 */
  182.   assem = gen_rtx (ASM_OPERANDS, VOIDmode, func, "=r", 0,
  183.                    rtvec_alloc(1), rtvec_alloc(1), "internal", 0);
  184.   XVECEXP (assem, 3, 0) = gen_rtx (REG, SImode, 0);
  185.   XVECEXP (assem, 4, 0) = gen_rtx (ASM_INPUT, SImode, "r");
  186.   fcall = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc(1+4));
  187.   XVECEXP (fcall, 0, 0)
  188.     = gen_rtx (SET, VOIDmode, stack_pointer, assem);
  189.   XVECEXP (fcall, 0, 1)
  190.     = gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, QImode, 9));
  191.   XVECEXP (fcall, 0, 2)
  192.     = gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, QImode, 8));
  193.   XVECEXP (fcall, 0, 3)
  194.     = gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, QImode, 1));
  195.   XVECEXP (fcall, 0, 4)
  196.     = gen_rtx (CLOBBER, VOIDmode, gen_rtx (REG, QImode, 0));  
  197.   return fcall; /* call function sp=func(d0) */
  198. }
  199.  
  200. rtx gen_stack_cleanup_call (stack_pointer,sa)
  201.      rtx stack_pointer;
  202.      rtx sa;
  203. {
  204.   return gen_stack_management_call (stack_pointer, sa, "jbsr ___move_d0_sp");
  205. }
  206.